import { LoginParams, LoginResponse, UserInfo, ResetPasswordResponse, UserProfileResponse, MenuListResponse } from '@/api/modules/loginModule';
import { UserInfoListResponse } from '@/api/modules/userModule';
import request from '@/utils/axios';

export const apiList = {
    login: '/login',
    userInfo: '/user/info',
    menu: '/menu/list',
    resetPassword: '/reset_password',
    userProfile: '/user_profile',
    editUserProfile: '/user_profile/edit',
    changePassword: '/change_password',
};

export const login = (params: LoginParams): Promise<LoginResponse> => {
    return request({
        url: apiList.login,
        method: 'post',
        data: params
    });
};

export const getUserInfo = (): Promise<UserInfo> => {
    return request({
        url: apiList.userInfo,
        method: 'get',
    });
};

export const resetPassword = (params: object): Promise<ResetPasswordResponse> => {
    return request({
        url: apiList.resetPassword,
        method: 'post',
        data: params
    });
};

export const getUserProfile = (params: object): Promise<UserProfileResponse> => {
    return request({
        url: apiList.userProfile,
        method: 'get',
        params: params
    });
};


export const changePassword = (params: object): Promise<ResetPasswordResponse> => {
    return request({
        url: apiList.changePassword,
        method: 'post',
        data: params
    });
};


export const editUserProfile = (params: object): Promise<UserInfoListResponse> => {
    return request({
        url: apiList.editUserProfile,
        method: 'put',
        data: params
    });
};

export const getMenuList = (params: object): Promise<MenuListResponse> => {
    return request({
        url: apiList.menu,
        method: 'get',
        params: params
    });
};
